package com.nb.provider.auth;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Slf4j
@Component
@WebFilter(urlPatterns = "/*", filterName = "requestWrapperFilter")
public class RequestWrapperFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        log.info("enter requestWrapperFilter doFilter");
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        MyRequestWrapper requestWrapper = new MyRequestWrapper(httpServletRequest);
        chain.doFilter(requestWrapper,response);
    }
}
